package com.zzyl.mapper;


import com.github.pagehelper.Page;
import com.zzyl.entity.NursingPlan;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface NursingPlanMapper {

    /**
     * 根据id查询护理计划
     *
     * @param id
     * @return
     */
    // todo 查看与前端测试的结果
   /* <select id="getById" parameterType="java.lang.Long" resultMap="NursingPlanMap">
    SELECT a.id,
    a.status,
    a.sort_no,
    a.plan_name,
    a.create_by,
    a.update_by,
    a.remark,
    a.create_time,
    a.update_time,
    p.id   as pid,
    plan_id,
    project_id,
    execute_time,
    execute_cycle,
    execute_frequency,
    p.create_by,
    p.update_by,
    p.remark,
    p.create_time,
    p.update_time,
    n.name as project_name
    from nursing_plan as a
    left join nursing_project_plan p ON p.plan_id = a.id
    left join nursing_project n on n.id = p.project_id
    WHERE a.id = #{id}
    </select>*/

    NursingPlan selectById(Long id);


    /**
     * 查询所有护理计划
     * @return
     */
    // todo 参考中是需要连表查询的 但接口文档并不需要，根据前端页面做出修改
   /* <select id="listAll" resultMap="NursingPlanMap">
    SELECT a.id,
    a.status,
    a.sort_no,
    a.plan_name,
    a.create_by,
    a.update_by,
    a.remark,
    a.create_time,
    a.update_time,
    p.id as pid,
    plan_id,
    project_id,
    execute_time,
    execute_cycle,
    execute_frequency,
    p.create_by,
    p.update_by,
    p.remark,
    p.create_time,
    p.update_time
    from nursing_plan as a
    left join nursing_project_plan p ON p.plan_id = a.id
    ORDER BY a.sort_no, a.create_time DESC
    </select>*/

    List<NursingPlan> getAllPlan();


    /**
     * 新增计划
     * @param nursingPlan
     */
    void addNursingPlan(NursingPlan nursingPlan);


    /**
     * 条件分页查询
     *
     * @param status
     * @return
     */
    Page<List<NursingPlan>> selectByPage(@Param("planName") String name, @Param("status") Integer status);


    /**
     * 修改
     *
     * @param nursingPlan1
     */
    void modifyPlan(NursingPlan nursingPlan1);


    /**
     * 根据id删除计划
     * @param id
     */
    @Delete("delete from nursing_plan where id=#{id};")
    void deleteById(Long id);


    /**
     * 启用禁用
     * @param id
     * @param status
     */
    void enableOrDisable(Long id, Integer status);


    /**
     * 根据名称查询
     * @param planName
     * @return
     */
    NursingPlan selectByName(String planName);
}
